import pandas as pd
import tushare as ts


def calculate_max_drawdown(code, start='2019-01-01', end='2019-11-21'):
    df = ts.get_hist_data(code, start=start, end=end)
    highest_close = df['close'].max()
    df['dropdown'] = (1 - df['close'] / highest_close)
    max_dropdown = df['dropdown'].max()
    print('max dropdown of %s is %.2f%s' % (code, max_dropdown * 100, '%'))


calculate_max_drawdown('002049')
